package com.example.controller;

import com.example.pojo.entity.Response;
import com.example.service.ResponseService;
import com.example.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 本文来演示
 *
 * @author 赵建云
 * @create 2023/10/21
 */
@RestController
@RequestMapping("response")
public class ResponseController {
    @Autowired
    private ResponseService responseService;
    @PostMapping("searchResponse")
    public Result searchResponse(String commentId){
        List<Response> list = responseService.findAllByCommentId(commentId);
        return new Result(200,"该评论下的所有回复",list);
    }
    @PostMapping("saveResponse")
    public Result saveResponse(Integer jsId,String commentId,String response,String optionJsName){
        System.out.println(jsId+","+commentId+","+response+","+optionJsName);
        int count = responseService.saveResponse(jsId, commentId, response,optionJsName);
        return new Result(200,"回复成功");
    }
    @PostMapping("addResponseLikeNum")
    public Result addResponseLikeNum(Integer jsId,String responseId){
        int count = responseService.addResponseLikeNum(jsId,responseId);
        return new Result(200,"点赞回复成功");
    }
}
